/**
 * 
 */
package name.webdizz.gadget.four.envelope.client.view.widgets;

import name.webdizz.gadget.four.envelope.client.StyleConstants;
import name.webdizz.gadget.four.envelope.client.domain.ExpenseItem;
import name.webdizz.gadget.four.envelope.client.domain.Goal;
import name.webdizz.gadget.four.envelope.client.event.CreditExpenseEventHandler;
import name.webdizz.gadget.four.envelope.client.event.CreditGoalEventHandler;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

/**
 * @author Izzet_Mustafayev
 * 
 */
public class ExpenseListUi extends Composite {

	private static ExpenseListUiBinder uiBinder = GWT
			.create(ExpenseListUiBinder.class);

	interface ExpenseListUiBinder extends UiBinder<Widget, ExpenseListUi> {
	}

	@UiField
	protected VerticalPanel panel;

	public ExpenseListUi() {
		initWidget(uiBinder.createAndBindUi(this));
	}

	public void addItemsTitle(final String title) {
		Label label = new Label(title);
		label.addStyleName(StyleConstants.BOLD);
		panel.add(label);
	}

	public void addItem(final Goal item,
			final CreditGoalEventHandler creditGoalHandler) {
		GoalItemUi ui = new GoalItemUi(item);
		ui.setCreditGoalEventHandler(creditGoalHandler);
		panel.add(ui);
	}

	public void addItem(final ExpenseItem item,
			final CreditExpenseEventHandler creditExpenseHandler) {
		ExpenselItemUi ui = new ExpenselItemUi(item);
		ui.setCreditExpenseEventHandler(creditExpenseHandler);
		panel.add(ui);
	}

}
